<script setup>
import { onMounted, ref } from 'vue'
import * as echarts from 'echarts'

const charts = ref()

onMounted(() => {
  const mychart = echarts.init(charts.value)
  mychart.setOption({
    title: {
      text: '年度对比图',
      left: 'center',
      textStyle: {
        color: '#22dea0',
        fontSize: 22,
      }
    },
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      data: ['2019', '2020']
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        type: 'scatter',
        data: [945, 2100, 1670, 1232, 2256, 2067, 1735, 2462, 2826, 1900, 1664,2183],
        symbol: 'arrow',
        symbolSize: 20,
        itemStyle: {
          color: '#22dea0'
        },
        label: {
          show: true,
          position: 'top',
          formatter: '{c}万元',
          textStyle: {
            color: '#22dea0'
          }
        }
      }
    ]
  })
})

</script>

<template>
  <div class="right-center">
    <div class="title">
      <p>年度对比</p>
      <img src="../../images/dataScreen-title.png" alt="">
    </div>

    <div class="charts" ref="charts">

    </div>
  </div>
</template>

<style scoped xml:lang="scss">

.right-center {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin-bottom: 20px;

  .title {
    margin-left: 10px;

    p {
      color: white;
      font-size: 20px;
    }
  }
}
.charts {
  width: 100%;
  height: calc(100% - 45px);
}


</style>